package com.example.isoftservice.advice;

import org.apache.shiro.authc.ExpiredCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionAdvice {
    @ExceptionHandler(DuplicateKeyException.class)
    public static String repeatUserName(){return "输入的用户名已存在!!!";}

    @ExceptionHandler(value = UnauthorizedException.class)
    public static String uhandler() {
        return "无权限操作";
    }

    @ExceptionHandler(value = ExpiredCredentialsException.class)
    public  static String echandler() {
        return "登录已过期，请重新登录";
    }


    @ExceptionHandler(value = UnauthenticatedException.class)
    public static String uchandler() {
        return"未登录";
    }
}
